package com.droidclaimsurveyor.dal;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;


public class ClaimInfoDBHelper extends SQLiteOpenHelper {
	public static final String DATABASE_TABLE 	= "claiminfo";
	public static final String DATABASE_NAME 	= "droidclaim.db";
	public static final int DATABASE_VERSION 	= 2;

	public static final String KEY_ID 				= "id";
	public static final String KEY_CLAIM_ID 		= "claimid";
	public static final String KEY_ACC_DATE 		= "accidentDate";
	public static final String KEY_ACC_LOCATION 	= "accidentLocation";
	public static final String KEY_ACC_LATITUDE 	= "accidentLatitude";
	public static final String KEY_ACC_LONGITUDE 	= "accidentLongitude";
	public static final String KEY_UPDATE_DATE 		= "updateDate";
	public static final String KEY_CLAIM_DOC_ID		= "claimDocId";
	public static final String KEY_LICENSEPLATENO 	= "licenseplateNo";
	public static final String KEY_CUST_NAME		= "custName";
	public static final String KEY_CUST_MOBILE		= "custMobile";
	public static final String KEY_CUST_IMAGE		= "custImgPath";
	public static final String KEY_CAR_COLOR		= "carColor";
	public static final String KEY_CAR_BRAND		= "carBrand";
	public static final String KEY_CAR_DETAIL		= "carDetail";
	public static final String KEY_INSURANCE_PACKAGE= "insurancePackage";

	private final String DATABASE_CREATE 		= "create table " + 
			DATABASE_TABLE + " (" + KEY_ID + " integer primary key autoincrement, " +
			KEY_CLAIM_ID + " integer, " +
			KEY_ACC_DATE + " varchar(256), " + 
			KEY_ACC_LOCATION + " varchar(256), " + 
			KEY_ACC_LATITUDE + " numberric, " + 
			KEY_ACC_LONGITUDE + " numberric, " + 
			KEY_UPDATE_DATE + " varchar(256), " + 
			KEY_CLAIM_DOC_ID + " integer, " + 
			KEY_LICENSEPLATENO + " varchar(32), " + 
			KEY_CUST_NAME + " varchar(256), " + 
			KEY_CUST_MOBILE + " varchar(10), " + 
			KEY_CUST_IMAGE + " varchar(512), " + 
			KEY_CAR_COLOR + " varchar(64), " + 
			KEY_CAR_BRAND + " varchar(64), " + 
			KEY_CAR_DETAIL + " varchar(256), " + 
			KEY_INSURANCE_PACKAGE + " varchar(64) );";
	
	public ClaimInfoDBHelper(Context context, String name,CursorFactory factory, int version) {
		super(context, name, factory, version);
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
        db.execSQL(DATABASE_CREATE);	
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		// drop table if exist
		db.execSQL("DROP TABLE IF EXISTS " + DATABASE_TABLE);
        // Create a new one.
        onCreate(db);
	}
}